// pages/index1/index1.js
var call = require("../../utils/ajax.js")
var Url = "http://localhost:8085/";
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */

    data: {
        URL: "",
        //模态框数据
        hideModal: true,
        sb: false,
        animationData: {}, //
        csspostion: "static",
        //宠物滚动信息
        srcollList: [],
        //寻宠/寻主
        searchList: [],
        M: {},
        Science: [],
        pageNo: 1,
        orginizeList: [],
        state: false,
        admin: {}
    },
    linkH: function(e) {
        console.log(e)
        let that = this;
        let motto = e.currentTarget.dataset.moto;
        let address = motto.organization_city_area + motto.organization_category + motto.organization_big_area;
        let message = {
            phone: motto.organization_contact,
            weixin: "暂无",
            adress: address
        }
        console.log(message)
        that.setData({
            admin: message,
            state: true
        })
    },
    onClose: function(e) {
        console.log(e)
        this.setData({
            state: false
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        this.setData({
            URL:app.globalData.URL
        })
        if (!app.globalData.userState) {
            try {
                wx.removeStorageSync('tokenID')
                wx.removeStorageSync('openID')
                console.log("喜欢iOS你")
            } catch (e) {
                // Do something when catch error 
            }
        }
        let that = this;
        let url = "Pet/selectManyPage?pageNum=1&pageSize=10";
        call.getData1(url, function(res) {
            console.log(res)
            let jj = res.data.list;
            console.log(jj)
            that.setData({
                srcollList: jj
            })
        }, function(e) {
            console.log(e)
        })

        let kk = this.lal().user_id;
        console.log(kk)
        if (kk != undefined) {
            that.setData({
                sb: false
            })
        } else {
            console.log("admin")
        }
        this.orginize();
    },
    lal: function() {
        let make = "";
        let kk = this;
        make = wx.getStorageSync('mm')
        return make;
    },
    orginize: function() {
        let that = this;
        let url = "Organization/getOrganization/1/10"
        call.getData1(url, function(res) {
            that.setData({
                orginizeList: res.date.list
            })
        }, function() {

        })
    },


    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {


    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        this.onLoad();
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },

    // 显示遮罩层
    showModal: function() {
        var that = this;
        that.setData({
            hideModal: false
        })

        var animation = wx.createAnimation({
            duration: 100, //动画的持续时间 默认400ms   数值越大，动画越慢   数值越小，动画越快
            timingFunction: 'ease', //动画的效果 默认值是linear
        })
        this.animation = animation
        setTimeout(function() {
            that.fadeIn(); //调用显示动画
        }, 100)
    },

    // 隐藏遮罩层
    hideModal: function() {
        var that = this;
        var animation = wx.createAnimation({
            duration: 100, //动画的持续时间 默认400ms   数值越大，动画越慢   数值越小，动画越快
            timingFunction: 'ease', //动画的效果 默认值是linear
        })
        this.animation = animation
        that.fadeDown(); //调用隐藏动画   
        setTimeout(function() {
                that.setData({
                    hideModal: true
                })
            }, 100) //先执行下滑动画，再隐藏模块

    },

    //动画集
    fadeIn: function() {
        this.animation.translateY(0).step()
        this.setData({
            animationData: this.animation.export() //动画实例的export方法导出动画数据传递给组件的animation属性
        })
    },
    fadeDown: function() {
        this.animation.translateY(300).step()
        this.setData({
            animationData: this.animation.export(),
        })
    }

})